<template>
  <div>
    <div class="DeliveryHandoverItem">
      <div class="title">
        <van-row>
          <van-col span="12">
            <h1>发货单：{{ data.deliverCargoNo }}</h1></van-col
          >
          <van-col span="12"
            ><p>发货时间：{{ data.deliverGoodsTime }}</p></van-col
          >
        </van-row>
      </div>
      <div class="DeliveryHandoverItemCon">
        <van-row>
          <van-col span="12">
            <div class="DeliveryHandoverItemConItem">
              <h1>发货类型：</h1>
              <p>{{ data.deliverGoodsType | deliverGoodsTypeShow }}</p>
            </div>
          </van-col>
          <van-col span="12">
            <div class="DeliveryHandoverItemConItem">
              <h1>装车服务：</h1>
              <p>{{ data.loadingService == 1 ? "是" : "否" }}</p>
            </div></van-col
          >
          <van-col span="12">
            <div class="DeliveryHandoverItemConItem">
              <h1>提&nbsp; 货&nbsp; 口：</h1>
              <p>{{ data.export }}</p>
            </div></van-col
          >
          <van-col span="12">
            <div class="DeliveryHandoverItemConItem">
              <h1>发货件重：</h1>
              <p>{{ data.deliverGoodsWeight }}</p>
            </div></van-col
          >
          <van-col span="12">
            <div class="DeliveryHandoverItemConItem">
              <h1>提 &nbsp;货&nbsp; 人：</h1>
              <p>{{ data.consigneeName }}</p>
            </div></van-col
          >
          <van-col span="12">
            <div class="DeliveryHandoverItemConItem">
              <h1>提货单位：</h1>
              <p title="d发斯蒂芬按时发生">{{ data.consigneeCompanyName }}</p>
            </div></van-col
          >
          <van-col span="12">
            <div class="DeliveryHandoverItemConItem">
              <h1>联系方式:</h1>
              <p>{{ data.contactNumber }}</p>
            </div></van-col
          >
          <van-col span="12">
            <div class="DeliveryHandoverItemConItem">
              <h1>车&nbsp; 牌&nbsp; 号：</h1>
              <p>{{ data.carNum }}</p>
            </div>
          </van-col>
        </van-row>
      </div>
      <div>
        <van-button class="button" @click="goWebPage(data.id)">交接</van-button>
      </div>
    </div>
  </div>
</template>

<script>
import Vue from "vue";
import { Col, Row, Button } from "vant";
import { startHandover } from "./../services/api";
import { getLocalhostUrl } from "./../utils/common";
Vue.use(Col);
Vue.use(Row);
Vue.use(Button);
export default {
  props: ["data"],
  methods: {
    // 打开新页面
    goWebPage(id) {
      startHandover({
        deliverCargoBillId: id,
      }).then((res) => {
        if (res.status) {
          Toast(res.message);
        } else {
          try {
            window.appPlat.goWebPage(
              getLocalhostUrl() + `/handoverDetails/${id}`
            );
          } catch (e) {
            this.$router.push(`/handoverDetails/${id}`);
          }
        }
      });
    },
  },
  filters: {
    deliverGoodsTypeShow(e) {
      if (e == 1) {
        return "发货出库";
      } else if (e == 2) {
        return "查验出库";
      } else if (e == 3) {
        return "整板出库";
      } else if (e == 4) {
        return "速提出库";
      } else {
        return "";
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.DeliveryHandoverItem {
  width: 100%;
  padding: 10px;
  box-sizing: border-box;
  background-color: #ffffff;
  border-radius: 15px;
  overflow: hidden;
  position: relative;
  margin-bottom: 10px;

  * {
    margin: 0;
    padding: 0;
  }

  .title {
    width: 100%;
    padding-bottom: 10px;
    border-bottom: 2px dotted #b4b7c9;

    h1 {
      font-size: 13px;
      font-weight: 400;
      color: #333333;
      line-height: 20px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    p {
      font-weight: 400;
      font-size: 10px;
      font-weight: 400;
      color: #8c9ba5;
      line-height: 20px;
      padding: 0 3px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
  }

  .DeliveryHandoverItemCon {
    width: 100%;
    padding-top: 15px;
    box-sizing: border-box;

    .DeliveryHandoverItemConItem {
      width: 100%;
      display: flex;

      & > h1 {
        width: 76px;
        font-size: 16px;
        font-weight: 400;
        color: #999999;
        line-height: 30px;
        white-space: nowrap;
        //overflow: hidden;
        text-overflow: ellipsis;
      }

      & > p {
        flex: 1;
        font-size: 16px;
        font-weight: 400;
        color: #333;
        line-height: 30px;
        //white-space: nowrap;
        //overflow: hidden;
        text-overflow: ellipsis;
        span {
          color: #f29d12;
        }
      }
    }
  }

  .button {
    margin: 15px 0 0 200px;
    width: 123px;
    border-radius: 15px;
    border: 2px solid #f39c12;
    font-size: 16px;
    font-weight: 500;
    color: #f39c12;
    background-color: #fff;
    line-height: 30px;
    height: 30px;
  }
}
</style>
